/*
 * Copyright © 2025 秋辞未寒 (545073804@qq.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gitee.colordreams.mapstruct.convert.util;

import io.gitee.colordreams.mapstruct.convert.mapper.BeanCopyMapper;
import io.gitee.colordreams.mapstruct.convert.mapper.MapperAware;
import io.gitee.colordreams.mapstruct.convert.mapper.SourceTargetMapper;
import io.gitee.colordreams.mapstruct.convert.factory.DefaultMapperFactory;
import io.gitee.colordreams.mapstruct.convert.factory.MapperFactory;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * Bean转换工具类
 *
 * @author 秋辞未寒
 */
public class BeanConvertUtil {

    /**
     * 默认MapperFactory
     */
    public static final MapperFactory DEFAULT_MAPPER_FACTORY = new DefaultMapperFactory();

    /**
     * MapperFactory
     */
    private static MapperFactory MAPPER_FACTORY = DEFAULT_MAPPER_FACTORY;

    /**
     * 设置MapperFactory
     *
     * @param mapperFactory MapperFactory
     */
    public static void setMapperFactory(final MapperFactory mapperFactory) {
        MAPPER_FACTORY = mapperFactory;
    }

    /**
     * 获取Mapper
     *
     * @param mapperClass Mapper字节码实例
     * @return Mapper
     */
    public static <M extends MapperAware> M getMapper(final Class<M> mapperClass) {
        return MAPPER_FACTORY.getMapper(mapperClass);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @return 目标对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> T toTarget(final Class<M> mapperClass, final S source) {
        return getMapper(mapperClass).toTarget(source);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).toTargetFunction();
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param after       转换后操作
     * @return 目标对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> T toTarget(final Class<M> mapperClass, final S source, final Consumer<T> after) {
        return getMapper(mapperClass).toTarget(source, after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param after       转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass, final Consumer<T> after) {
        return getMapper(mapperClass).toTargetFunction(after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param after       转换后操作
     * @return 目标对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> T toTarget(final Class<M> mapperClass, final S source, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toTarget(source, after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param after       转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toTargetFunction(after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param target      目标对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toTarget(final Class<M> mapperClass, final S source, final T target) {
        getMapper(mapperClass).toTarget(source, target);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass, final T target) {
        return getMapper(mapperClass).toTargetFunction(target);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param target      目标对象
     * @param after       转换后操作
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toTarget(final Class<M> mapperClass, final S source, final T target, final Consumer<T> after) {
        getMapper(mapperClass).toTarget(source, target, after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param after       转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass, final T target, final Consumer<T> after) {
        return getMapper(mapperClass).toTargetFunction(target, after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param target      目标对象
     * @param after       转换后操作
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toTarget(final Class<M> mapperClass, final S source, final T target, final BiConsumer<S, T> after) {
        getMapper(mapperClass).toTarget(source, target, after);
    }

    /**
     * 将源对象转换为目标对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param after       转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<S, T> toTargetFunction(final Class<M> mapperClass, final T target, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toTargetFunction(target, after);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param sourceList  源对象列表
     * @return 目标对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<T> toTargetList(final Class<M> mapperClass, final List<S> sourceList) {
        return getMapper(mapperClass).toTargetList(sourceList);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<S>, List<T>> toTargetListFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).toTargetListFunction();
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param sourceList  源对象列表
     * @param eachAfter   每一个元素转换后操作
     * @return 目标对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<T> toTargetList(final Class<M> mapperClass, final List<S> sourceList, final Consumer<T> eachAfter) {
        return getMapper(mapperClass).toTargetList(sourceList, eachAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param eachAfter   每一个元素转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<S>, List<T>> toTargetListFunction(final Class<M> mapperClass, final Consumer<T> eachAfter) {
        return getMapper(mapperClass).toTargetListFunction(eachAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param sourceList  源对象列表
     * @param eachAfter   每一个元素转换后操作
     * @return 目标对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<T> toTargetList(final Class<M> mapperClass, final List<S> sourceList, final BiConsumer<S, T> eachAfter) {
        return getMapper(mapperClass).toTargetList(sourceList, eachAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param eachAfter   每一个元素转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<S>, List<T>> toTargetListFunction(final Class<M> mapperClass, final BiConsumer<S, T> eachAfter) {
        return getMapper(mapperClass).toTargetListFunction(eachAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param sourceList  源对象列表
     * @param listAfter   列表转换后操作
     * @return 目标对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<T> toTargetListAll(final Class<M> mapperClass, final List<S> sourceList, final Consumer<List<T>> listAfter) {
        return getMapper(mapperClass).toTargetListAll(sourceList, listAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param listAfter   列表转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<S>, List<T>> toTargetListAllFunction(final Class<M> mapperClass, final Consumer<List<T>> listAfter) {
        return getMapper(mapperClass).toTargetListAllFunction(listAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param sourceList  源对象列表
     * @param listAfter   列表转换后操作
     * @return 目标对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<T> toTargetListAll(final Class<M> mapperClass, final List<S> sourceList, final BiConsumer<List<S>, List<T>> listAfter) {
        return getMapper(mapperClass).toTargetListAll(sourceList, listAfter);
    }

    /**
     * 将源对象列表转换为目标对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param listAfter   列表转换后操作
     * @return 目标对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<S>, List<T>> toTargetListAllFunction(final Class<M> mapperClass, final BiConsumer<List<S>, List<T>> listAfter) {
        return getMapper(mapperClass).toTargetListAllFunction(listAfter);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @return 源对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> S toSource(final Class<M> mapperClass, final T target) {
        return getMapper(mapperClass).toSource(target);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).toSourceFunction();
    }


    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param after       转换后操作
     * @return 源对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> S toSource(final Class<M> mapperClass, final T target, final Consumer<S> after) {
        return getMapper(mapperClass).toSource(target, after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param after       转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass, final Consumer<S> after) {
        return getMapper(mapperClass).toSourceFunction(after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param after       转换后操作
     * @return 源对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> S toSource(final Class<M> mapperClass, final T target, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toSource(target, after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param after       转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toSourceFunction(after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param source      源对象
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toSource(final Class<M> mapperClass, final T target, final S source) {
        getMapper(mapperClass).toSource(target, source);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass, final S source) {
        return getMapper(mapperClass).toSourceFunction(source);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param source      源对象
     * @param after       转换后操作
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toSource(final Class<M> mapperClass, final T target, final S source, final Consumer<S> after) {
        getMapper(mapperClass).toSource(target, source, after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param after       转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass, final S source, final Consumer<S> after) {
        return getMapper(mapperClass).toSourceFunction(source, after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param target      目标对象
     * @param source      源对象
     * @param after       转换后操作
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> void toSource(final Class<M> mapperClass, final T target, final S source, final BiConsumer<S, T> after) {
        getMapper(mapperClass).toSource(target, source, after);
    }

    /**
     * 将目标对象转换成源对象
     *
     * @param mapperClass Mapper字节码实例
     * @param source      源对象
     * @param after       转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<T, S> toSourceFunction(final Class<M> mapperClass, final S source, final BiConsumer<S, T> after) {
        return getMapper(mapperClass).toSourceFunction(source, after);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param targetList  目标对象列表
     * @return 源对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<S> toSourceList(final Class<M> mapperClass, final List<T> targetList) {
        return getMapper(mapperClass).toSourceList(targetList);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<T>, List<S>> toSourceListFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).toSourceListFunction();
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param targetList  目标对象列表
     * @param eachAfter   每一个元素转换后操作
     * @return 源对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<S> toSourceList(final Class<M> mapperClass, final List<T> targetList, final Consumer<S> eachAfter) {
        return getMapper(mapperClass).toSourceList(targetList, eachAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param eachAfter   每一个元素转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<T>, List<S>> toSourceListFunction(final Class<M> mapperClass, final Consumer<S> eachAfter) {
        return getMapper(mapperClass).toSourceListFunction(eachAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param targetList  目标对象列表
     * @param eachAfter   每一个元素转换后操作
     * @return 源对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<S> toSourceList(final Class<M> mapperClass, final List<T> targetList, final BiConsumer<S, T> eachAfter) {
        return getMapper(mapperClass).toSourceList(targetList, eachAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param eachAfter   每一个元素转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<T>, List<S>> toSourceListFunction(final Class<M> mapperClass, final BiConsumer<S, T> eachAfter) {
        return getMapper(mapperClass).toSourceListFunction(eachAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param targetList  目标对象列表
     * @param listAfter   列表转换后操作
     * @return 源对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<S> toSourceListAll(final Class<M> mapperClass, final List<T> targetList, final Consumer<List<S>> listAfter) {
        return getMapper(mapperClass).toSourceListAll(targetList, listAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param listAfter   列表转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<T>, List<S>> toSourceListAllFunction(final Class<M> mapperClass, final Consumer<List<S>> listAfter) {
        return getMapper(mapperClass).toSourceListAllFunction(listAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param targetList  目标对象列表
     * @param listAfter   列表转换后操作
     * @return 源对象列表
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> List<S> toSourceListAll(final Class<M> mapperClass, final List<T> targetList, final BiConsumer<List<S>, List<T>> listAfter) {
        return getMapper(mapperClass).toSourceListAll(targetList, listAfter);
    }

    /**
     * 将目标对象列表转换成源对象列表
     *
     * @param mapperClass Mapper字节码实例
     * @param listAfter   列表转换后操作
     * @return 源对象转换函数
     */
    public static <S, T, M extends SourceTargetMapper<S, T>> Function<List<T>, List<S>> toSourceListAllFunction(final Class<M> mapperClass, final BiConsumer<List<S>, List<T>> listAfter) {
        return getMapper(mapperClass).toSourceListAllFunction(listAfter);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param bean        对象
     * @return 拷贝对象
     */
    public static <T, M extends BeanCopyMapper<T>> T copy(final Class<M> mapperClass, final T bean) {
        return getMapper(mapperClass).copy(bean);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @return 拷贝对象
     */
    public static <T, M extends BeanCopyMapper<T>> Function<T, T> copyFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).copyFunction();
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param bean        对象
     * @param after       拷贝后操作
     * @return 拷贝对象
     */
    public static <T, M extends BeanCopyMapper<T>> T copy(final Class<M> mapperClass, final T bean, final Consumer<T> after) {
        return getMapper(mapperClass).copy(bean, after);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param after       拷贝后操作
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<T, T> copyFunction(final Class<M> mapperClass, final Consumer<T> after) {
        return getMapper(mapperClass).copyFunction(after);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param bean        对象
     * @param targetBean  拷贝后的目标对象
     */
    public static <T, M extends BeanCopyMapper<T>> void copy(final Class<M> mapperClass, final T bean, final T targetBean) {
        getMapper(mapperClass).copy(bean, targetBean);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param targetBean  拷贝后的目标对象
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<T, T> copyFunction(final Class<M> mapperClass, final T targetBean) {
        return getMapper(mapperClass).copyFunction(targetBean);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param bean        对象
     * @param targetBean  拷贝后的目标对象
     * @param after       拷贝后操作
     */
    public static <T, M extends BeanCopyMapper<T>> void copy(final Class<M> mapperClass, final T bean, final T targetBean, final Consumer<T> after) {
        getMapper(mapperClass).copy(bean, targetBean, after);
    }

    /**
     * 拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param targetBean  拷贝后的目标对象
     * @param after       拷贝后操作
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<T, T> copyFunction(final Class<M> mapperClass, final T targetBean, final Consumer<T> after) {
        return getMapper(mapperClass).copyFunction(targetBean, after);
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param beans       对象列表
     * @return 拷贝对象列表
     */
    public static <T, M extends BeanCopyMapper<T>> List<T> copyList(final Class<M> mapperClass, final List<T> beans) {
        return getMapper(mapperClass).copyList(beans);
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<List<T>, List<T>> copyListFunction(final Class<M> mapperClass) {
        return getMapper(mapperClass).copyListFunction();
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param beans       对象列表
     * @param eachAfter   每一个元素拷贝后操作
     * @return 拷贝对象列表
     */
    public static <T, M extends BeanCopyMapper<T>> List<T> copyList(final Class<M> mapperClass, final List<T> beans, final Consumer<T> eachAfter) {
        return getMapper(mapperClass).copyList(beans, eachAfter);
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param eachAfter   每一个元素拷贝后操作
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<List<T>, List<T>> copyListFunction(final Class<M> mapperClass, final Consumer<T> eachAfter) {
        return getMapper(mapperClass).copyListFunction(eachAfter);
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param beans       对象列表
     * @param listAfter   对象列表拷贝后操作
     * @return 拷贝对象列表
     */
    public static <T, M extends BeanCopyMapper<T>> List<T> copyListAll(final Class<M> mapperClass, final List<T> beans, final Consumer<List<T>> listAfter) {
        return getMapper(mapperClass).copyListAll(beans, listAfter);
    }

    /**
     * 批量拷贝对象
     *
     * @param mapperClass Mapper字节码实例
     * @param listAfter   对象列表拷贝后操作
     * @return 拷贝对象函数
     */
    public static <T, M extends BeanCopyMapper<T>> Function<List<T>, List<T>> copyListAllFunction(final Class<M> mapperClass, final Consumer<List<T>> listAfter) {
        return getMapper(mapperClass).copyListAllFunction(listAfter);
    }

}
